<template>
  <el-container>
    <el-header class="topheader" v-show="isvisible">
      <TopMenu @hidetop="hidetop"></TopMenu>
    </el-header>
    <el-container style="margin: 0" v-show="islogin">
      <el-aside :class="theme" style="width: 220px" v-show="isvisible">
        <menu-side @chang="chang" @changview="changview" ref="menu"></menu-side>
      </el-aside>
      <el-aside :class="theme_hide" style="width: 220px" v-show="!isvisible">
        <menu-side @chang="chang" @changview="changview" ref="menu"></menu-side>
      </el-aside>
      <el-container>
        <el-header class="mheader" v-show="isvisible">
          <mHeader></mHeader>
        </el-header>
        <el-header class="mheader hidetop" v-show="!isvisible">
          <mHeader></mHeader>
        </el-header>
        <router-view style=" margin-left: 190px"></router-view>
        <el-footer class="footer">Copyright © Your Website 2021</el-footer>
      </el-container>
    </el-container>
    <router-view v-show="!islogin"></router-view>
  </el-container>
</template>

<script>
import MenuSide from '../components/MenuSide.vue'
import TopMenu from '../components/TopMenu.vue'
import mHeader from '../components/mHeader.vue'
export default {
  name: 'App',
  components: { MenuSide, TopMenu, mHeader },
  data() {
    return {
      isvisible: true,
      islogin: true,
      to: "999",
      theme: '',
      theme_hide: ''
    }
  },
  computed: {
    changetheme() {
      return this.$store.state.theme
    }
  },
  watch: {
    $route(to, from) {
      this.to = to.path
    },
    changetheme: {
      handler(newval) {
        this.theme = 'left_aside' + ' ' + newval
        this.theme_hide = 'left_aside hidetop' + ' ' + newval
      },
      immediate: true,
      deep: true
    }
  },
  mounted() {
    this.changview()
  },
  methods: {
    changview(val) {
      if (val === '/login') {
        this.islogin = false
        console.log(val)
      }

    },
    hidetop() {
      this.isvisible = !this.isvisible
    },
    chang(val) {
      if (val === "/login") {
        this.islogin = false
      }
    }
  }
}
</script>

<style>
@import '../assets/less/theme.less';

.topheader {
  text-align: center;
  line-height: 60px;
  position: fixed;
  right: 0;
  width: 100%;
  top: 0px;
  z-index: 99;
  border-bottom: 3px solid rgb(220, 57, 45);
  background-color: rgb(255, 255, 255);
}

.mheader {
  height: 70px;
  margin-top: 60px;
  margin-left: 230px;
}

.el-aside {
  height: 100%;
  position: fixed;
  top: 60px;
  left: 0;
  width: 220px !important;
  z-index: 10;
}

.hidetop {
  top: 0;
  margin-top: 0px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.footer {
  font-size: 12.8px;
  font-weight: 400;
  line-height: 60px;
  margin-left: 230px;
  text-align: center;
  color: rgb(133, 135, 150);
  font-family: Nunito;
}
</style>